<template>
  <a-modal
      title="添加押金"
      :width="650"
      :visible="Jsvisible"
      :confirmLoading="JsconfirmLoading"
      @cancel="JshandleCancel"
      @ok="handleSubmit"
    >
      <a-table
        :columns="columnsJsDio"
        :data-source="loadDataJsDio"
        :rowKey="(record) => record.furnitureid"
        :row-selection="rowJsSelection"
        :pagination='false'>
      </a-table>
    </a-modal>
</template>
<script>
  import { busRoomConfigurationList } from '@/api/modular/main/busroomconfiguration/busRoomConfigurationManage'
  export default {
    data() {
      return {
        // 彈出框列表
        loadDataJsDio: [],
        // 已選擇的押金-未保存 -key
        selectedRowKeysJsDio: [],
        selectedRowsJsDio: [],
        columnsJsDio: [
          {
            title: '名稱',
            dataIndex: 'name'
          }
        ],
        Jsvisible: false,
        JsconfirmLoading: false
      }
    },
    computed: {
      rowJsSelection() {
        return {
          onChange: this.onSelectChangeJsDio,
          selectedRowKeys: this.selectedRowKeysJsDio,
          getCheckboxProps: record => ({
            props: {
              disabled: record.disabled,
              name: record.name
            }
          })
        }
      }
    },
    created() {
    },
    methods: {
      add () {
        this.Jsvisible = true
         busRoomConfigurationList().then((res) => {
            const reldata = []
            if (res.code === 200) {
              if (res.data.length > 0) {
                for (var i = 0; i < res.data.length; i++) {
                  reldata.push({ disabled: false, name: res.data[i].name, furnitureid: res.data[i].id })
                }
                this.loadDataJsDio = reldata
              }
            } else {
              this.$message.error(res.msg)
            }
          })
      },
      onSelectChangeJsDio (selectedRowKeys, selectedRows) {
        this.selectedRowKeysJsDio = selectedRowKeys
        this.selectedRowsJsDio = selectedRows
      },
      handleSubmit () {
        this.$emit('ok', this.selectedRowsJsDio)
        this.Jsvisible = false
        this.selectedRowsJsDio = []
        this.selectedRowKeysJsDio = []
      },
      JshandleCancel () {
        this.selectedRowsJsDio = []
        this.selectedRowKeysJsDio = []
        this.Jsvisible = false
      }
    }
}
</script>
<style lang="less">
</style>
